package asia.lxq.cic.config;

import asia.lxq.cic.entity.Result;
import asia.lxq.cic.entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(RuntimeException.class)//制定由该异常处理
    @ResponseBody
    public Result<Object> Sense(RuntimeException runtimeException){
        runtimeException.printStackTrace();
        return Result.buildOrigin(StatusCode.FORBIDDEN,null,runtimeException.getMessage(),false);
    }
}
